import { useEffect } from 'react';
import { connect } from 'react-redux';
import utils from '@/utils/index';

const GetOpenId = ({ dispatch, path = '' }) => {
  useEffect(() => {
    let openId = utils.getLocalOpenId();
    if (!openId) {
      utils.getOpenId(dispatch, path);
    } else {
      dispatch({ type: 'login/setOpenId', payload: openId });
    }
  });

  return null;
};

export default connect()(GetOpenId);
